package com.kwum;

import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.ThreadLocalRandom;

/**
 * Hello world!
 *
 */
public class App {
	public static ThreadLocalRandom random = ThreadLocalRandom.current();
    public static void main( String[] args ){
//        System.out.println( "Hello World!" );
//        int sum = 0;
//        int count = 50;
//        for (int i = 0; i < 5; i++) {
//			int one = randomInt(10, 20);
//			if (count < sum + one) {
//				if (count - sum > 5) {
//					System.out.println(count - sum);
//				}
//				break;
//			} else {
//				System.out.println(one);
//				sum = sum + one;
//			}
//		}
//        
//        long seconds = Duration.between(LocalDateTime.parse("2018-02-11" + " " + "08:20:00", 
//				DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), LocalDateTime.parse("2018-02-10" + " " + "07:10:00", 
//				DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))).getSeconds();
//        System.out.println(Math.abs(seconds)/3600 > 24 && seconds < 0);
//        
//        System.out.println(System.currentTimeMillis());
        
        // 设置边界
        String BOUNDARY = "----" + System.currentTimeMillis();
        StringBuilder sb = new StringBuilder();
		sb.append("--" + BOUNDARY); // 必须多两道线
		sb.append("\r\n");
		sb.append("Content-Disposition: form-data; name=\"timestamp\"");
		sb.append("\r\n");
		sb.append("\r\n");
		sb.append(System.currentTimeMillis());
		sb.append("\r\n");
		sb.append("--" + BOUNDARY); // 必须多两道线
		sb.append("\r\n");
		sb.append("Content-Disposition: form-data; name=\"id\"");
		sb.append("\r\n");
		sb.append("\r\n");
		sb.append("WU_FILE_0");
		sb.append("\r\n");
		sb.append("--" + BOUNDARY); // 必须多两道线
		sb.append("\r\n");
		sb.append("Content-Disposition: form-data; name=\"name\"");
		sb.append("\r\n");
		sb.append("\r\n");
		//TODO
		sb.append("yeah");
		sb.append("\r\n");
		sb.append("--" + BOUNDARY); // 必须多两道线
		sb.append("\r\n");
		sb.append("Content-Disposition: form-data; name=\"type\"");
		sb.append("\r\n");
		sb.append("\r\n");
		sb.append("video/mp4");
		sb.append("\r\n");
		sb.append("--" + BOUNDARY); // 必须多两道线
		sb.append("\r\n");
		sb.append("Content-Disposition: form-data; name=\"size\"");
		sb.append("\r\n");
		sb.append("\r\n");
		//TODO
		sb.append("17181366");
		sb.append("\r\n");
		sb.append("--" + BOUNDARY); // 必须多两道线
		sb.append("\r\n");
		sb.append("Content-Disposition: form-data; name=\"chunks\"");
		sb.append("\r\n");
		sb.append("\r\n");
		sb.append("1");
		sb.append("\r\n");
		sb.append("--" + BOUNDARY); // 必须多两道线
		sb.append("\r\n");
		sb.append("Content-Disposition: form-data; name=\"chunk\"");
		sb.append("\r\n");
		sb.append("\r\n");
		sb.append("0");
		sb.append("\r\n");
		sb.append("--" + BOUNDARY); // 必须多两道线
		sb.append("\r\n");
		sb.append("Content-Disposition: form-data; name=\"upload_key\"");
		sb.append("\r\n");
		sb.append("\r\n");
		sb.append("731c04ba425c8d72886f07a3d50b8452");
		sb.append("\r\n");
		sb.append("--" + BOUNDARY); // 必须多两道线
		sb.append("\r\n");
		//TODO
		sb.append("Content-Disposition: form-data;name=\"file\";filename=\"" + "yeah" + "\"\r\n");
		sb.append("Content-Type:application/octet-stream\r\n\r\n");
		System.out.println(sb.toString());
    }
    
    public static int randomInt(int start, int end) {

		int differ = end - start;

		return random.nextInt(10000) % differ + start;
	}
}
